{include file="index@index/head" /}
<div class="membox">
  <div class="wrap"> {include file="index@index/member/menu" /}
    <div class="mright">
      <div class="mtit">
        <h2>账户信息</h2>
      </div>
      <form method="post" action="{:url('Member/saveAccount')}" data-type="account">          
        <div class="mem-form">									
            <ul class="form">
							<li><span>会员头像</span>
									<div class="mem-head">
											<input type="hidden" name="head" value="{$one.head}">
											<div class="uploadThumb">
															<div class="pic"><img src="{$one.head|default='/img/mem/head.png'}" alt=""></div>
											</div>
									</div>
							</li>
							<li><span><i>*</i>手机号码 ：</span> <div class="intxt">{$meminfo.mobile} </div></li>
							<li><span>电子邮箱 ：</span>
											<input type="text" name="email" maxlength="50" value="{$one.email}" autocomplete="off" placeholder="请输入邮箱" class="intxt">
							</li>
							<li><span><i>*</i>呢称 ：</span>
											<input type="text" name="name" maxlength="20" id="a_name" value="{$one.name}" autocomplete="off" placeholder="请输入呢称" class="intxt">
							</li> 
									<li><span><i>*</i>性别 ：</span>
													<div><input type="radio" value="1" {if condition="$one.gender eq 1"}checked{/if} name="gender">男 &nbsp;&nbsp;&nbsp;<input type="radio" {if condition="$one.gender eq 2"}checked{/if} value="2" name="gender">女</div>
									</li>
									<li><span>详细地址 ：</span>
											<input type="text" name="address" maxlength="255" id="a_address" value="{$one.address}" autocomplete="off" placeholder="请输入详细地址" class="intxt">
							</li>
							<li><span><i>*</i>简介：</span>
											<textarea name="remark"  maxlength="200" placeholder="请输入个人简介" id="a_remark" class="intxt" style="height:120px; resize:none;">{$one.remark}</textarea>
							</li>
							<li class="b">
											<span></span>
											<input type="submit" class="btns" value="保存">
							</li>
            </ul>
        </div>
      </form>
    </div>
  </div>
</div>
<script src="{$ROOT}/public/layui/layui.js"></script> 
<script>
$(document).on('submit', 'form[data-type=account]',function() {
    var url = $(this).attr('action');	
    var data = $(this).serializeArray();			
				if($("#a_name").val().trim()==""){
					layer.msg("请输入呢称");
					return false;
				}					
				if($("#a_remark").val().trim()==""){
					layer.msg("请输入个人简介");
					return false;
				}		
				var load = layer.load(1);
    $.post(url, data,function(res) {
		layer.close(load);
        if (res.code == 1) {
            layer.alert(res.msg, {icon: 1},function(){
                window.location.reload();
            });
        } else {
            layer.alert(res.msg, {
                icon: 2
            });
        }
    },"JSON");
    return false;
})

//上传缩略图
layui.use('upload',function() {
    var upload = layui.upload;
    var uploadInst = upload.render({
        elem: '.uploadThumb' //绑定元素
        ,
        url: "{:url('uploadImage')}" //上传接口
        ,
        accept: 'images',
        acceptMime: 'image/*',
        done: function(res) {
            if (res.code == 0) {
                $("input[name=head]").val(res.url);
                $(".uploadThumb").find("img").attr("src", res.url);
            } else {
                layer.alert(res.msg, {
                    icon: 2
                });
            }
        },
        error: function(res) {
            layer.msg(res);
        }
    });
});
</script> 
{include file="index@index/foot" /} 